package com.legal.domain.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户信息表
 * </p>
 *
 * @author xiaopeng
 * @since 2025-03-29
 */
@Data
@EqualsAndHashCode(callSuper = false) // equals 和 hashCode
@Accessors(chain = true) // 链式编程风格
@TableName("tb_user")
@Schema(name = "User", description = "用户信息表")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "自增主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "用户编号，业务唯一标识", example = "U10001")
    private String userNo;

    @Schema(description = "用户账号", example = "user123")
    private String userAccount;

    @Schema(description = "用户昵称", example = "法务助手")
    private String nickname;

    @Schema(description = "真实姓名", example = "张三")
    private String realName;

    @Schema(description = "密码哈希")
    private String passwordHash;

    @Schema(description = "用户角色版本号-监听权限变更", example = "1")
    private Integer roleVersion;

    @Schema(description = "封禁版本号", example = "0")
    private Integer banVersion;

    @Schema(description = "是否启用（1启用 0禁用）", example = "1")
    private Integer isEnabled;

    @Schema(description = "是否管理员（1是 0否）", example = "0")
    private Integer isAdmin;

    @Schema(description = "帐号状态（0正常 1停用）", example = "0")
    private Integer accountStatus;

    @Schema(description = "手机号", example = "13800138000")
    private String phoneNumber;

    @Schema(description = "邮箱", example = "user@example.com")
    private String email;

    @Schema(description = "性别（0男 1女 2未知）", example = "0")
    private String sex;

    @Schema(description = "头像地址", example = "https://example.com/avatar.jpg")
    private String avatarUrl;

    @Schema(description = "最后登录IP", example = "192.168.1.1")
    private String lastIp;

    @Schema(description = "最后登录时间", example = "2025-06-20 15:30:00")
    private LocalDateTime lastLoginTime;

    @Schema(description = "创建人", example = "system")
    private String creator;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "创建时间", example = "2025-03-29 10:00:00")
    private LocalDateTime createTime;

    @Schema(description = "用户积分", example = "100")
    private Integer points;

    @Schema(description = "更新人", example = "admin")
    private String updater;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "更新时间", example = "2025-06-20 16:00:00")
    private LocalDateTime updateTime;
}